package com.example.a14110100420.yuejian.Fragment;


import android.os.Bundle;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.example.a14110100420.yuejian.Fragment.club.Renqi_ClubFragment;
import com.example.a14110100420.yuejian.R;
import com.example.a14110100420.yuejian.WAdapter.club.ClubViewpagerAdatper;

import java.util.ArrayList;
import java.util.List;

/**
 * A simple {@link Fragment} subclass.
 */
public class ClubFragment extends Fragment {
    private ImageView search;
    private View view;
    private TabLayout tabs;
    private ViewPager viewPager;
    private List<String> title = new ArrayList<>();
    private List<Fragment> fragments = new ArrayList<>();


    public ClubFragment() {
    }


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        view = inflater.inflate(R.layout.tab02, container, false);


        showFragemt();
        onclick();
        ClubViewpagerAdatper adatper = new ClubViewpagerAdatper(getChildFragmentManager(), title, fragments);
        viewPager.setAdapter(adatper);
        tabs.setupWithViewPager(viewPager);


        return view;
    }

    private void  showFragemt(){
        tabs = view.findViewById(R.id.tabs_club);
        viewPager = view.findViewById(R.id.viewPager);
        title.add("最具人气");
        title.add("最近距离");
        fragments.add(new Renqi_ClubFragment());
        fragments.add(new Renqi_ClubFragment());
    }
    private void onclick(){
        search = view.findViewById(R.id.search_button);
        search.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

            }
        });

    }


}
